package com.mxf.example.web.mq;

import com.mxf.example.config.rebbit.MQConstant;
import com.mxf.example.mq.FirstSender;
import com.mxf.example.utils.http.Result;

import io.swagger.annotations.Api;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping(value = "/api/mq", produces = "application/json;charset=UTF-8")
@Api(value = "消息队列相关接口", tags = {"消息队列相关接口"})
public class MqController {
    @Autowired
    private FirstSender firstSender;


    @GetMapping("/send")
    @ApiOperation(value = "测试发送消息", notes = "测试发送消息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "message", value = "消息", required = true, dataType = "String")
    })
    public Result<String> send(String message) {
        System.out.println("发送时间:" + System.currentTimeMillis());
        firstSender.send(MQConstant.HELLO_QUEUE_NAME, "延时消息" + message, 6000);

        message = "测试普通消息";
        firstSender.send(MQConstant.HELLO_QUEUE_NAME, message);
        return Result.createSuccess(System.currentTimeMillis() + "");
    }
}
